﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace N03
{
    // 不同的人开不同的车
   public interface ICar
    {
        void Run();
    }

    public interface IDriver
    {
        void Drive();
        void SetCar(ICar car);
    }


    // 构造方法注入
    public class Benz:ICar
    {
        public void Run() {
            Console.WriteLine("奔驰正在跑");
        }
    }

    public class  Student:IDriver
    {
        private ICar _car;
        public void Drive()
        {
            _car.Run();
        }

        public void SetCar(ICar car)
        {
            _car = car;
        }
    }

}


